package com.ejuornal.util;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.ejuornal.bean.vo.Email;

public class ThreadPool {
	 /* pool config */
   
    
    private static ThreadPoolExecutor pool;
    private static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
    
    static {
        /** 
         *  使用JDK中的线程池，线程执行采用无边界策略
         */
        pool = new ThreadPoolExecutor(Constants.COREPOOLSIZE, Constants.MAXIMUMPOOLSIZE, 2, TimeUnit.MINUTES, queue); 
    }
    
    public void sendEmail(Email email) {
    	EmailThread et = new EmailThread(email);
    	pool.execute(et);
    	pool.shutdown();
    }
    
   
}
